package world.liuru.poem.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.GenericGenerator;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedBy;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;
import java.util.Date;

@Data
@Entity
@DynamicInsert
@Table(name = "POEM")
@EntityListeners(AuditingEntityListener.class)
public class Poem {

    @Id
    @Column(name = "ID")
    @GeneratedValue(generator = "id")
    @GenericGenerator(name = "id",strategy = "org.hibernate.id.UUIDGenerator")
    private String id;

    @Column(name = "TITLE",columnDefinition = "varchar(300) not null comment '标题'")
    private String title;

    @Column(name = "CONTENT",columnDefinition = "text comment '内容'")
    private String content;

    @Column(name = "IMG_URL",columnDefinition = "varchar(500) comment '图片'")
    private String imgUrl;

    @Column(name = "BACKGROUD",columnDefinition = "text comment '背景'")
    private String background;

    @Column(name = "AUTHOR",columnDefinition = "varchar(255) not null comment '作者'")
    private String author;

    @Column(name = "CREATE_DATE",columnDefinition = "date comment '创建日期'")
    @CreatedDate
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private Date createDate;

    @Column(name = "LAST_UPDATE_BY",columnDefinition = "varchar(255) comment '上次更新者'")
    @LastModifiedBy
    private String lastUpdateBy;

    @Column(name = "LAST_UPDATE_DATE",columnDefinition = "date comment '上次更新时间'")
    @LastModifiedDate
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private Date lastUpdateDate;

}
